/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.figures;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.CompoundBorder;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.swt.graphics.Color;

import edu.pku.sei.modeler.figures.CommonFigure;
import edu.pku.sei.modeler.uml.ResourceFactory;
import edu.pku.notation.runtime.draw2d.*;
import edu.pku.notation.runtime.layout.*;

/**
 * @generated
 *
 */
public class ObjectNodeFigure extends CommonFigure {
	public static final org.eclipse.swt.graphics.Color OBJECTNODE_COLOR = new Color(null,175,178,239);
	public IFigure root = null;
	
	private TextFigure objectNodeLabel = null;
	
	public ObjectNodeFigure(){
		super();
		XYLayout xyL = new XYLayout();
		setLayoutManager(xyL);
		setOpaque(true);
		
		root = new RectangleFigure();
		root.setOpaque(true);
		root.setForegroundColor(ColorConstants.blue);
		add(root);
		
		objectNodeLabel = new TextFigure();
		objectNodeLabel.setOpaque(false);
		objectNodeLabel.setFont(ResourceFactory.getHeadFont());
		objectNodeLabel.setForegroundColor(ColorConstants.black);
		objectNodeLabel.setBackgroundColor(ColorConstants.white);
		add(objectNodeLabel);
	}
	
	public void changeLineColor(Color color) {
		this.setForegroundColor(color);
		root.setForegroundColor(color);
	}
	
	public TextFigure getObjectNodeLabel() {
		return objectNodeLabel;
	}
	
	public void setBounds(Rectangle rect) {
		super.setBounds(rect);
		if (root != null)
			root.setSize(rect.width, rect.height);
		if (objectNodeLabel != null){
			objectNodeLabel.setSize(rect.width, rect.height);
		}
	}
	protected void paintShadow(Graphics g) {
		// TODO: draw the figure's own shadow here
	}
}
